<%@ page contentType="text/html; charset=utf-8" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/tlds/struts-tags.tld" prefix="s"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>



<!-- Affichage des actionmessage -->
<h2>s:actiomessage</h2>
<s:actionmessage cssStyle="color:blue" />


<!-- formulaire simpliste champ / submit -->
<h2>s:form, s:textfield; s:submit</h2>
<s:form action="test">
	<label>Texte</label>
	<s:textfield name="champTexte" />
	<label>Entier</label>
	<s:textfield name="champEntier" />
	<s:submit></s:submit>
</s:form>


<!-- formulaire simpliste fichier / submit -->
<h2>s:form, s:file, s:submit</h2>
<s:form action="test" enctype="multipart/form-data">
	<s:file name="fichier"></s:file>
	<s:submit></s:submit>
</s:form>


<!-- formulaire et fielderror -->
<h2>s:form, s:textfield, s:submit, s:fielderror</h2>
<s:form action="test">
	<label>Texte (en erreur si on saisit "erreur")</label>
	<s:textfield name="champTexte2" />
	<s:submit></s:submit>

	<p>fielderror simple :</p>
	<s:fielderror cssStyle="color:red"></s:fielderror>

	<p>fielderror avec fieldName="champ" :</p>
	<s:fielderror fieldName="champ" cssStyle="color:purple"></s:fielderror>
</s:form>

<!-- formulaire et actionError-->
<h2>s:form, s:textfield, s:submit,s:action</h2>
<s:form action="test">
	<label>Texte (en erreur si on saisit "erreur")</label>
	<s:textfield name="champTexte3" />
	<s:submit></s:submit>

	<p>actionerror :</p>
	<s:actionerror cssStyle="color:red" />

</s:form>

<!-- Gestion de la présence d'erreurs et de messages-->
<h2>s:form, s:textfield, s:submit,s:action, hasActionErrors(),
	hasFieldErrors(), hasActionMessages()</h2>
<s:form action="test">
	<label>Texte (en erreur si on saisit "erreur", "field" pour une
		fielderror)</label>
	<s:textfield name="champTexte4" />
	<s:submit></s:submit>

	<s:if test="hasActionMessages()">
		<p>actionmessage :</p>
		<s:actionmessage cssStyle="color:blue" />
	</s:if>

	<s:if test="hasActionErrors()">
		<p>actionerror :</p>
		<s:actionerror cssStyle="color:red" />
	</s:if>

	<s:if test="hasFieldErrors()">
		<p>fieldError :</p>
		<s:fielderror cssStyle="color:orange" />
	</s:if>

</s:form>

<h2>s:select à partir de List</h2>
<s:form action="test">
	<s:select list="listeSelect1" name="cleSelect1"></s:select>
	<s:submit></s:submit>
</s:form>

<h2>s:select à partir de Map</h2>
<s:form action="test">
	<s:select list="mapSelect2" name="cleSelect2"></s:select>
	<s:submit></s:submit>
</s:form>

<!-- conditions if else -->
<h2>s:if / s:else</h2>
<table class="table">
	<thead>
		<tr>
			<th>condition du test = true</th>
			<th>condition du test = false</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td><s:if test="true">affichage du s:if</s:if></td>
			<td></td>
		</tr>
		<tr>
			<td><s:if test="false"></s:if></td>
			<td><s:else>affichage du s:else</s:else></td>
		</tr>
		<tr>
			<td><s:if test="getTrue()">getTrue() retourne true</s:if></td>
			<td><s:else>getTrue() retourne false</s:else></td>
		</tr>

	</tbody>
</table>

<h2>s:date</h2>
<s:date name="dateDuJour" format="dd/MM/yyyy" />


<!-- s:iterator -->
<h2>s:iterator / s:property sur une liste</h2>
<table class="table">
	<thead>
		<tr>
			<th>Texte</th>
			<th>Nombre</th>
			<th>Hello World</th>
		</tr>
	</thead>
	<tbody>
		<s:iterator value="listeMonObjet">
			<tr>
				<td><s:property value="texte"/></td>
				<td><s:property value="nombre"/></td>
				<td><s:property value="helloWorld"/></td>
			</tr>

		</s:iterator>
	</tbody>
</table>